package com.joplus.housekeeper.bean;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;
import java.util.ArrayList;

import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;

/**
 * author： ccm
 * time： 2017/7/11.
 * description：
 */

public class XmppUser extends RealmObject implements Parcelable {
    @PrimaryKey
    private String userName;
    private String nickName;
    private String avatar;


    private String lastConversation;
    private long lastConversationTime;
    private int unRead = 0;
    private String accountId;
    private String memberId;

    public String getMemberId() {
        return memberId;
    }

    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }

    public long getLastConversationTime() {
        return lastConversationTime;
    }

    public void setLastConversationTime(long lastConversationTime) {
        this.lastConversationTime = lastConversationTime;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public int getUnRead() {
        return unRead;
    }

    public void setUnRead(int unRead) {
        this.unRead = unRead;
    }

    private RealmList<XmppMessage> xmppMessages;

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public static Creator<XmppUser> getCREATOR() {
        return CREATOR;
    }

    public RealmList<XmppMessage> getXmppMessages() {
        return xmppMessages;
    }

    public void setXmppMessages(RealmList<XmppMessage> xmppMessages) {
        this.xmppMessages = xmppMessages;
    }

    public String getLastConversation() {
        return lastConversation;
    }

    public void setLastConversation(String lastConversation) {
        this.lastConversation = lastConversation;
    }

    public XmppUser() {

    }

    public XmppUser(String username, String password) {

        userName = username;

    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.userName);
        dest.writeString(this.nickName);
        dest.writeString(this.lastConversation);
        dest.writeLong(this.lastConversationTime);
        dest.writeInt(this.unRead);
        dest.writeString(this.avatar);
        dest.writeString(this.accountId);
        dest.writeString(this.memberId);
        dest.writeList(this.xmppMessages);
    }

    protected XmppUser(Parcel in) {
        this.userName = in.readString();
        this.nickName = in.readString();
        this.lastConversation = in.readString();
        this.lastConversationTime = in.readLong();
        this.unRead = in.readInt();
        this.avatar = in.readString();
        this.accountId = in.readString();
        this.memberId = in.readString();
        this.xmppMessages = new RealmList<>();
        in.readList(this.xmppMessages, XmppMessage.class.getClassLoader());
    }

    public static final Parcelable.Creator<XmppUser> CREATOR = new Parcelable.Creator<XmppUser>() {
        @Override
        public XmppUser createFromParcel(Parcel source) {
            return new XmppUser(source);
        }

        @Override
        public XmppUser[] newArray(int size) {
            return new XmppUser[size];
        }
    };
}
